/**
 *
 */
package org.platform.core.filecommand;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

@Slf4j
@Deprecated
public class BaseFileCommandFactory {

    public static BaseFileCommandFactory getInstance() {
        return new BaseFileCommandFactory();
    }

    public IFileCommand getFileCommand(String fileName) {
        String[] fileTypes = fileName.split("_");
        if (fileTypes.length < 1) {
            return null;
        }
        String fileType = fileTypes[0];
        String iFileCommandName = StringUtils.join("org.platform.core.filecommand.impl.", fileType, "FileCommand");
        try {
            Class<?> commandClassName = Class.forName(iFileCommandName);
            return (IFileCommand) commandClassName.newInstance();
        } catch (Exception e) {
            log.error("未找到对应的实现类: ", e);
            return null;
        }
    }

}
